package com.yunhe.java.pro12JiHe;

import com.yunhe.java.pro11JiHe.Course;

import java.util.*;


/**
 * Created by Administrator on 2017/8/5 0005.
 */
public class JiHeSet  {


    public static void main(String[] args) {
//        Course course = new Course();
//        List courseList = new ArrayList();
//        Iterator iterator = courseList.iterator();
//        while (iterator.hasNext()) {
//            Object obj = iterator.next();
//            System.out.println(obj);
//        }

        Student stu1 = new Student("严秀", 25);
        Student stu2 = new Student("张三", 23);
        Student stu3 = new Student("李四", 24);
        Student stu4 = new Student("王五", 26);

        //  HashSet及遍历
//        Set<Student> set = new HashSet<>();
//        set.add(stu1);
//        set.add(stu2);
//        set.add(stu3);
//        set.add(stu4);

//        Iterator iterator = set.iterator();
//        while (iterator.hasNext()) {
//            Object obj = iterator.next();
//            System.out.println(obj);

        //TreeSet comparable排序及遍历
        Set<Student> abc = new TreeSet<>();
        abc.add(stu1);
        abc.add(stu2);
        abc.add(stu3);
        abc.add(stu4);

        Iterator iterator = abc.iterator();
        while (iterator.hasNext()) {
            Object obj = iterator.next();
            System.out.println(obj);

        }
    }
}
